#pragma once 

#include<iostream>
#include<string>
#include<cstring>

#define SEP " "
#define SEP_LEN strlen(SEP)

enum {OK = 0, DIV_ZERO ,MOD_ZERO ,OP_ERROR};

const std::string& enLength(const std::string& text)
{

}

const std::string& deLength(const std::string& package)
{

}

class Request
{
public:
    Request():x(0),y(0)
    {}
    Request(const int& x_,const int& y_,const char& op_):x(x_),y(y_),op(op_)
    {}
    bool serialize(std::string *out)
    {
        //x op y
        *out="";
        std::string x_string = std::to_string(x);
        std::string y_string = std::to_string(y);

        *out = x_string;
        *out += SEP;
        *out += op;
        *out += SEP;
        *out += y_string;
        return true;
    }
    bool deserialize(const std::string &in)
    {
        //x op y
        auto left = in.find(SEP);
        auto right = in.rfind(SEP);
        if(left==std::string::npos||right==std::string::npos) return false;
        if(left == right)  return false;
        if(right - (left+SEP_LEN) != 1) return false;

        std::string x_string = in.substr(0,left);
        std::string y_string = in.substr(right+SEP_LEN);
        if(x_string.empty()) return false;
        if(y_string.empty()) return false;

        x=std::stoi(x_string);
        y=std::stoi(y_string);
        op=in[left+SEP_LEN];
        return true;
    }
public:
    int x;
    int y;
    int op;
};


class Response
{
public:
    Response():exitcode(0),result(0)
    {}
    bool serialize(std::string *out)
    {
      
    }
    bool deserialize(const std::string &in)
    {
        
    }
public:
    int exitcode;
    int result;
};

